﻿<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Navegar.UAP.Exemple.CRM.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:format="using:WinRTConverters.Format"
    xmlns:Visibility="using:WinRTConverters.Visibility"
    x:Class="Navegar.UAP.Exemple.CRM.Views.ListCommandesPage"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
    	<Visibility:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <format:StringFormatConverter x:Key="StringFormatConverter"/>
        <DataTemplate x:Key="CommandeTemplate">
        	<Grid Margin="0,0,0,20">
        		<Grid.RowDefinitions>
        			<RowDefinition Height="Auto"/>
        			<RowDefinition Height="Auto"/>
        		</Grid.RowDefinitions>
        		<Grid.ColumnDefinitions>
        			<ColumnDefinition/>
        			<ColumnDefinition Width="Auto"/>
        		</Grid.ColumnDefinitions>
        		<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="0" TextWrapping="Wrap" Text="{Binding NumeroCommande}" VerticalAlignment="Top" FontSize="18.667" FontWeight="Bold"/>
        		<TextBlock HorizontalAlignment="Left" Margin="0" Grid.Row="1" TextWrapping="Wrap" Text="{Binding NumeroClient}" VerticalAlignment="Top" FontSize="14.667"/>
        		<TextBlock Grid.Column="1" HorizontalAlignment="Center" Margin="30,0,0,0" TextWrapping="Wrap" Text="{Binding TotalCommande, ConverterParameter=Total : \{0\} €, Converter={StaticResource StringFormatConverter}}" VerticalAlignment="Top" Grid.RowSpan="2" FontSize="24" Foreground="#FF1A90C7" FontWeight="Bold"/>
        	</Grid>
        </DataTemplate>
    </Page.Resources>
    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton
        		HorizontalAlignment="Left"
        		VerticalAlignment="Top"
        		Command="{Binding AddCommand}"
        		Icon="Add"
        		Label="Ajouter" FontFamily="Global User Interface"/>
            <AppBarButton
        		HorizontalAlignment="Left"
        		VerticalAlignment="Top"
        		Command="{Binding CancelCommand}"
        		Icon="Cancel"
        		Label="Fermer" FontFamily="Global User Interface" Visibility="{Binding IsWindowsApp, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        </CommandBar>
    </Page.BottomAppBar>
    <Page.DataContext>
        <Binding Path="ListCommandesPageViewModelInstance" Source="{StaticResource Locator}"/>
    </Page.DataContext>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="120"/>
			<RowDefinition Height="1"/>
			<RowDefinition/>
		</Grid.RowDefinitions>
		<TextBlock Grid.Row="0" Margin="40,0,0,0" TextWrapping="Wrap" Text="Liste des commandes" VerticalAlignment="Center" FontSize="32" HorizontalAlignment="Left"/>
		<Line Grid.Row="1" Stroke="White" X2="1" Margin="40,0" Stretch="Fill"/>
		<ListView x:Name="listView" Margin="40,30" Grid.Row="2" ItemsSource="{Binding Commandes}" SelectedItem="{Binding SelectedCommande, Mode=TwoWay}" ItemTemplate="{StaticResource CommandeTemplate}"/>
	</Grid>
</Page>
